function Person(sex) {
    this.sex = sex
}
var person = new Person('boy')
person.name = '冯总'
person.age = 18
person.like = {
            sport:'running',
            food:'beef'
        }
Person.prototype.weight = 140      


function deepCopy(obj) {
    // var obj2 = obj instanceof Array ? [] : {}
    // for (let i in obj) {
    //     if (obj[i] instanceof Object) {
    //         obj2[i] = deepCopy(i)
    //     } else{
    //         if (obj.hasOwnProperty(i)) {
    //             obj2[i] = obj[i]
    //         }
    //     }
    // }
    // return obj2

    let copy = obj instanceof Array ? [] : {}
    for (let i in obj) {
        if (obj.hasOwnProperty(i)) {
            copy[i] = obj[i] instanceof Object ? deepCopy(obj[i]) : obj[i]
        }
    }
    return copy
}

let newPerson = deepCopy(person)
person.age.like = 'swimming'
console.log(newPerson);  